import { _decorator, Component, NodeEventType, profiler, Sprite, SpriteFrame, Tween, Vec3 } from 'cc';
const { ccclass, property } = _decorator;
@ccclass('FilterFusionDemo')
export class FilterFusionDemo extends Component {
    @property({ type: [SpriteFrame] })
    bgFrames: SpriteFrame[] = [];
    bgFrameId: number = 0;
    sprites: Sprite[] = [];
    protected onLoad(): void {
        profiler.hideStats();
        this.sprites = this.node.getComponentsInChildren(Sprite);
        this.sprites.shift();
        this.node.on(NodeEventType.TOUCH_START, () => {
            let frame = this.bgFrames[++this.bgFrameId % this.bgFrames.length];
            for (let spts = this.sprites, i = spts.length - 1; i >= 0; i--) {
                let spt = spts[i];
                new Tween(spt.node)
                    .delay(0.04 * i)
                    .to(0.05, { scale: new Vec3(1.2, 1.2, 1) })
                    .call(() => { spt.spriteFrame = frame; })
                    .to(0.05, { scale: new Vec3(1, 1, 1) })
                    .call(() => {
                        new Tween(spt.getComponent(gi.FilterFusion)).set({ strength: 0 }).to(1.5, { strength: 1 }).start();
                    }).start();
            }
        }, this);
    }
}